package com.merlin.demo_wellshape;

import com.merlin.demo_wellshape.pojo.DailyQuote;
import com.merlin.demo_wellshape.repository.DailyQuoteRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;

import java.util.Arrays;
import java.util.List;

@SpringBootApplication
public class DemoWellShapeApplication {
    @Autowired
    private DailyQuoteRepository dailyQuoteRepository;

    public static void main(String[] args) {
        SpringApplication.run(DemoWellShapeApplication.class, args);
    }

    // 初始化数据库
    @Bean
    public CommandLineRunner initDatabase() {
        return args -> {
            // 检查数据库是否为空
            if (dailyQuoteRepository.count() == 0) {
                List<DailyQuote> initialQuotes = Arrays.asList(
                        new DailyQuote("坚持就是胜利。"),
                        new DailyQuote("每天进步一点点。"),
                        new DailyQuote("塑造不止于型，更是生活的超燃引擎。"),
                        new DailyQuote("每一程蜕变，都有WellShape的专业相伴。"),
                        new DailyQuote("以科学塑形，让热爱有型。"),
                        new DailyQuote("放弃很容易，但坚持下来，用WellShape塑造的身材会更耀眼。"),
                        new DailyQuote("解锁健身新姿态，WellShape与你共塑精彩。"),
                        new DailyQuote("以热爱之名，雕琢健身者的理想体魄。"),
                        new DailyQuote("健身的坚持，藏在日复一日的重复里，WellShape为你记录每一次进步。"),
                        new DailyQuote("踏上健身征途，WellShape 为你量身定制蜕变之路。"),
                        new DailyQuote("三天打鱼两天晒网，身材怎能有模样？WellShape陪你持久续航。"),
                        new DailyQuote("WellShape与健身的你，同塑坚韧，共筑完美。"),
                        new DailyQuote("每天多一次深蹲，WellShape 陪你离完美身材更近一步。"),
                        new DailyQuote("一次健身是冲动，持续健身是蜕变，WellShape陪你完成这场进化。"),
                        new DailyQuote("甩掉累赘，拥抱纯粹，WellShape为你雕琢理想身形。")
                );

                dailyQuoteRepository.saveAll(initialQuotes);
            }
        };
    }
}
